using TestCases.CompareAssert.Core.Builders;
using TestCases.CompareAssert.Core.Comparers.Interfaces;
using TestCases.CompareAssert.Core.Interfaces;

namespace TestCases.CompareAssert.Core.Comparers.Stateless
{
    public class EqualsComparer : IObjectComparer
    {
        public const string IdentifiableName = "EqualsComparer";
        private static readonly EqualsComparer _instance = new EqualsComparer();

// Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
// ReSharper disable EmptyConstructor
        static EqualsComparer()
// ReSharper restore EmptyConstructor
        {
        }

        private EqualsComparer()
        {
        }

        public static EqualsComparer Instance
        {
            get { return _instance; }
        }

        public string Name
        {
            get { return IdentifiableName; }
        }

        public IResultBuilder Compare(ICompareContext context)
        {
            return this.IsBoolResult(context.LValue.Equals(context.RValue), context).
                ForEquals("<{LPath}>.Equals(<{RPath}>) is true [{LValue}.Equals({RValue}) == true].").
                ForNotEquals("<{LPath}>.Equals(<{RPath}>) is false [{LValue}.Equals({RValue}) == false].");
        }
    }
}